﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace CVSS.Client.SC.UI
{
    public partial class UIDateTime : UserControl
    {
        public UIDateTime()
        {
            InitializeComponent();
        }

        private void StartHour_Validating(object sender, CancelEventArgs e)
        {
            if (StartDateTime > EndDateTime)
            {
                MessageBox.Show("开始时间大于结束时间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                StartHour.Value = 0;
                StartMinute.Value = 0;
            }
        }

        public DateTime StartDateTime
        {
            get
            {
                return Convert.ToDateTime(Convert.ToDateTime(this.dTP.Text).AddHours(Convert.ToDouble(this.StartHour.Value)).AddMinutes(Convert.ToDouble(this.StartMinute.Value)));
            }
        }

        public DateTime EndDateTime
        {
            get
            {
                return Convert.ToDateTime(Convert.ToDateTime(this.dTP.Text).AddHours(Convert.ToDouble(this.EndHour.Value)).AddMinutes(Convert.ToDouble(this.EndMinute.Value)));
            }
        }
    }
}
